#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
using namespace std;

class Solution
{
public:
	vector<string> findWords(vector<string>& words)
	{
		vector<string> ret;
		auto check = [](char c)
			{			
				switch (tolower(c))
				{
				case 'q':	case 'w':	case 'e':	case 'r':
				case 't':	case 'y':	case 'u':	case 'i':
				case 'o':	case 'p':
					return 1;
				case 'a':	case 's':	case 'd':	case 'f':
				case 'g':	case 'h':	case 'j':	case 'k':
				case 'l':
					return 2;
				case 'z':	case 'x':	case 'c':	case 'v':
				case 'b':	case 'n':	case 'm':
					return 3;
				default:
					break;
				}
				return 0;
			};
		auto getsum = [&](int a, char c) {return a + check(c); };
		for (const string& i:words)
		{
			if (accumulate(i.begin(), i.end(), 0, getsum) == i.size()*check(i[0]))
				ret.push_back(i);
		}
		return ret;
	}
	
};


int main()
{
	Solution t;
	vector<string> input{ "Hello","Alaska","Dad","Peace" };
	vector<string> ret = t.findWords(input);
	for (int i = 0; i < ret.size(); ++i)
		cout << ret[i] << endl;
		

}
